

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MC_CONST_H
#define __MC_CONST_H

/* Includes ------------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/

#define divSQRT_3	(s16) 0x49E6    /* 1/sqrt(3) in q1.15 format=0.5773315*/
/* Offset for cos(Theta)=sin_cos_Table[index_sin+offset]*/
#define OFFSET 		64	
#define SQRT_3		1.732051
#define PI        3.1416
#define SQRT_2    1.4142

//to be deleted if not used by anyone
#define q0dot5            ((s16) 0x4000)       		//0.5 in 1.5
#define qSqrtd2           ((s16) 0x6ED9) 					//sqrt3/2 in 1.15
#define	qSqrt_inverse            0x5A11						//sqrt(3)* Vdc_invT
#define	qSqrtd2_inverse          0x2D0f						//(sqrt(3))/2* Vdc_invT
#define	q3d2_inverse             0x4E0C						//3/2* Vdc_invT

#define SPEED_CONTROL           (u32)0x0001
#define FIRST_START             (u32)0x0002
#define START_UP_FAILURE        (u32)0x0004
#define SPEED_FEEDBACK          (u32)0x0008
#define BRAKE_ON                (u32)0x0010
#define OVERHEAT                (u32)0x0100
#define OVER_CURRENT            (u32)0x0200
#define OVER_VOLTAGE            (u32)0x0400
#define UNDER_VOLTAGE           (u32)0x0800

/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
/* Exported variables ------------------------------------------------------- */
#define SIN_COS_TABLE { \
0, 101, 201, 302, 402, 503, 603, 704, 804, 905, 1005, 1106, 1206, 1307, 1407, \
1507, 1608, 1708, 1809, 1909, 2009, 2110, 2210, 2310, 2410, 2511, 2611, 2711, \
2811, 2911, 3012, 3112, 3212, 3312, 3412, 3512, 3612, 3712, 3811, 3911, 4011, \
4111, 4210, 4310, 4410, 4509, 4609, 4708, 4808, 4907, 5007, 5106, 5205, 5305, \
5404, 5503, 5602, 5701, 5800, 5899, 5998, 6096, 6195, 6294, 6393, 6491, 6590, \
6688, 6786, 6885, 6983, 7081, 7179, 7277, 7375, 7473, 7571, 7669, 7767, 7864, \
7962, 8059, 8157, 8254, 8351, 8448, 8545, 8642, 8739, 8836, 8933, 9030, 9126, \
9223, 9319, 9416, 9512, 9608, 9704, 9800, 9896, 9992, 10087, 10183, 10278, \
10374, 10469, 10564, 10659, 10754, 10849, 10944, 11039, 11133, 11228, 11322, \
11417, 11511, 11605, 11699, 11793, 11886, 11980, 12074, 12167, 12260, 12353, \
12446, 12539, 12632, 12725, 12817, 12910, 13002, 13094, 13187, 13279, 13370, \
13462, 13554, 13645, 13736, 13828, 13919, 14010, 14101, 14191, 14282, 14372, \
14462, 14553, 14643, 14732, 14822, 14912, 15001, 15090, 15180, 15269, 15358, \
15446, 15535, 15623, 15712, 15800, 15888, 15976, 16063, 16151, 16238, 16325, \
16413, 16499, 16586, 16673, 16759, 16846, 16932, 17018, 17104, 17189, 17275, \
17360, 17445, 17530, 17615, 17700, 17784, 17869, 17953, 18037, 18121, 18204, \
18288, 18371, 18454, 18537, 18620, 18703, 18785, 18868, 18950, 19032, 19113, \
19195, 19276, 19357, 19438, 19519, 19600, 19680, 19761, 19841, 19921, 20000, \
20080, 20159, 20238, 20317, 20396, 20475, 20553, 20631, 20709, 20787, 20865, \
20942, 21019, 21096, 21173, 21250, 21326, 21403, 21479, 21554, 21630, 21705, \
21781, 21856, 21930, 22005, 22079, 22154, 22227, 22301, 22375, 22448, 22521, \
22594, 22667, 22739, 22812, 22884, 22956, 23027, 23099, 23170, 23241, 23311, \
23382, 23452, 23522, 23592, 23662, 23731, 23801, 23870, 23938, 24007, 24075, \
24143, 24211, 24279, 24346, 24413, 24480, 24547, 24613, 24680, 24746, 24811, \
24877, 24942, 25007, 25072, 25137, 25201, 25265, 25329, 25393, 25456, 25519, \
25582, 25645, 25708, 25770, 25832, 25893, 25955, 26016, 26077, 26138, 26198, \
26259, 26319, 26378, 26438, 26497, 26556, 26615, 26674, 26732, 26790, 26848, \
26905, 26962, 27019, 27076, 27133, 27189, 27245, 27300, 27356, 27411, 27466, \
27521, 27575, 27629, 27683, 27737, 27790, 27843, 27896, 27949, 28001, 28053, \
28105, 28157, 28208, 28259, 28310, 28360, 28411, 28460, 28510, 28560, 28609, \
28658, 28706, 28755, 28803, 28850, 28898, 28945, 28992, 29039, 29085, 29131, \
29177, 29223, 29268, 29313, 29358, 29403, 29447, 29491, 29534, 29578, 29621, \
29664, 29706, 29749, 29791, 29832, 29874, 29915, 29956, 29997, 30037, 30077, \
30117, 30156, 30195, 30234, 30273, 30311, 30349, 30387, 30424, 30462, 30498, \
30535, 30571, 30607, 30643, 30679, 30714, 30749, 30783, 30818, 30852, 30885, \
30919, 30952, 30985, 31017, 31050, 31082, 31113, 31145, 31176, 31206, 31237, \
31267, 31297, 31327, 31356, 31385, 31414, 31442, 31470, 31498, 31526, 31553, \
31580, 31607, 31633, 31659, 31685, 31710, 31736, 31760, 31785, 31809, 31833, \
31857, 31880, 31903, 31926, 31949, 31971, 31993, 32014, 32036, 32057, 32077, \
32098, 32118, 32137, 32157, 32176, 32195, 32213, 32232, 32250, 32267, 32285, \
32302, 32318, 32335, 32351, 32367, 32382, 32397, 32412, 32427, 32441, 32455, \
32469, 32482, 32495, 32508, 32521, 32533, 32545, 32556, 32567, 32578, 32589, \
32599, 32609, 32619, 32628, 32637, 32646, 32655, 32663, 32671, 32678, 32685, \
32692, 32699, 32705, 32711, 32717, 32722, 32728, 32732, 32737, 32741, 32745, \
32748, 32752, 32755, 32757, 32759, 32761, 32763, 32765, 32766, 32766, 32767}


#define SQRTAB1 {\
		 0, 		4096, 	5793,	 7094, 	8192,	 9159, 10033, 10837,\
     11585, 12288, 12953, 13585, 14189, 14768, 15326, 15864,\
     16384, 16888, 17378, 17854, 18318, 18770, 19212, 19644,\
     20066, 20480, 20886, 21283, 21674, 22058, 22435, 22806,\
     23170, 23530, 23884, 24232, 24576, 24915, 25249, 25580,\
     25905, 26227, 26545, 26859, 27170, 27477, 27780, 28081,\
     28378, 28672, 28963, 29251, 29537, 29819, 30099, 30377,\
     30652, 30924, 31194, 31462, 31727, 31991, 32252, 32511,\
     32768, 33023, 33276, 33527, 33776, 34024, 34270, 34514,\
     34756, 34996, 35235, 35472, 35708, 35942, 36175, 36406,\
     36636, 36864, 37091, 37316, 37540, 37763, 37985, 38205,\
     38424, 38642, 38858, 39073, 39287, 39500, 39712, 39923,\
     40132, 40341, 40548, 40755, 40960, 41164, 41368, 41570,\
     41771, 41972, 42171, 42369, 42567, 42763, 42959, 43154,\
     43348, 43541, 43733, 43925, 44115, 44305, 44494, 44682,\
     44869, 45056, 45242, 45427, 45611, 45795, 45977, 46160,\
     46341, 46522, 46702, 46881, 47059, 47237, 47415, 47591,\
     47767, 47942, 48117, 48291, 48465, 48637, 48809, 48981,\
     49152, 49322, 49492, 49661, 49830, 49998, 50166, 50332,\
     50499, 50665, 50830, 50995, 51159, 51323, 51486, 51649,\
     51811, 51972, 52134, 52294, 52454, 52614, 52773, 52932,\
     53090, 53248, 53405, 53562, 53719, 53874, 54030, 54185,\
     54340, 54494, 54647, 54801, 54954, 55106, 55258, 55410,\
     55561, 55712, 55862, 56012, 56162, 56311, 56459, 56608,\
     56756, 56903, 57051, 57198, 57344, 57490, 57636, 57781,\
     57926, 58071, 58215, 58359, 58503, 58646, 58789, 58931,\
     59073, 59215, 59357, 59498, 59639, 59779, 59919, 60059,\
     60199, 60338, 60477, 60615, 60753, 60891, 61029, 61166,\
     61303, 61440, 61576, 61712, 61848, 61984, 62119, 62254,\
     62388, 62523, 62657, 62790, 62924, 63057, 63190, 63323,\
     63455, 63587, 63719, 63850, 63982, 64113, 64243, 64374,\
     64504, 64634, 64763, 64893, 65022, 65151, 65279, 65408}

#define SQRTAB2 {\
		 32768, 32768, 32769, 32770, 32772, 32774, 32777, 32780,\
     32784, 32788, 32793, 32798, 32804, 32810, 32817, 32824,\
     32832, 32840, 32849, 32858, 32868, 32878, 32889, 32900,\
     32912, 32924, 32937, 32950, 32963, 32978, 32992, 33007,\
     33023, 33039, 33056, 33073, 33090, 33108, 33127, 33146,\
     33166, 33186, 33206, 33227, 33248, 33270, 33293, 33316,\
     33339, 33363, 33387, 33412, 33437, 33463, 33489, 33516,\
     33543, 33570, 33598, 33627, 33656, 33685, 33715, 33746,\
     33776, 33808, 33839, 33872, 33904, 33937, 33971, 34005,\
     34039, 34074, 34110, 34145, 34182, 34218, 34255, 34293,\
     34331, 34369, 34408, 34447, 34487, 34527, 34568, 34609,\
     34650, 34692, 34734, 34777, 34820, 34863, 34907, 34952,\
     34996, 35041, 35087, 35133, 35179, 35226, 35273, 35321,\
     35369, 35417, 35466, 35515, 35565, 35615, 35665, 35716,\
     35767, 35818, 35870, 35922, 35975, 36028, 36081, 36135,\
     36189, 36244, 36299, 36354, 36410, 36466, 36522, 36579,\
     36636, 36693, 36751, 36809, 36868, 36926, 36986, 37045,\
     37105, 37165, 37226, 37287, 37348, 37410, 37471, 37534,\
     37596, 37659, 37722, 37786, 37850, 37914, 37979, 38044,\
     38109, 38174, 38240, 38306, 38373, 38439, 38507, 38574,\
     38642, 38710, 38778, 38846, 38915, 38985, 39054, 39124,\
     39194, 39264, 39335, 39406, 39477, 39549, 39620, 39693,\
     39765, 39838, 39911, 39984, 40057, 40131, 40205, 40279,\
     40354, 40429, 40504, 40579, 40655, 40731, 40807, 40883,\
     40960, 41037, 41114, 41192, 41269, 41347, 41425, 41504,\
     41582, 41661, 41741, 41820, 41900, 41980, 42060, 42140,\
     42221, 42301, 42382, 42464, 42545, 42627, 42709, 42791,\
     42874, 42956, 43039, 43122, 43206, 43289, 43373, 43457,\
     43541, 43625, 43710, 43795, 43880, 43965, 44051, 44136,\
     44222, 44308, 44394, 44481, 44568, 44654, 44741, 44829,\
     44916, 45004, 45092, 45180, 45268, 45356, 45445, 45534,\
     45623, 45712, 45801, 45891, 45980, 46070, 46160, 46251,\
     46341, 46432}	
		 
#define ATANTAB1 { \
				0,	 41, 	 81, 	122, 	163, 	204, 	244, 	285, 	326, 	367, 	407, 	448, 	489, 	529, 	570, 	610,\
			651,  692,  732,  773,  813,  854,  894,  935,  975, 1015, 1056, 1096, 1136, 1177, 1217, 1257,\
     1297, 1337, 1377, 1417, 1457, 1497, 1537, 1577, 1617, 1656, 1696, 1736, 1775, 1815, 1854, 1894,\
     1933, 1973, 2012, 2051, 2090, 2129, 2168, 2207, 2246, 2285, 2324, 2363, 2401, 2440, 2478, 2517,\
     2555, 2594, 2632, 2670, 2708, 2746, 2784, 2822, 2860, 2897, 2935, 2973, 3010, 3047, 3085, 3122,\
     3159, 3196, 3233, 3270, 3307, 3344, 3380, 3417, 3453, 3490, 3526, 3562, 3599, 3635, 3670, 3706,\
     3742, 3778, 3813, 3849, 3884, 3920, 3955, 3990, 4025, 4060, 4095, 4129, 4164, 4199, 4233, 4267,\
     4302, 4336, 4370, 4404, 4438, 4471, 4505, 4539, 4572, 4605, 4639, 4672, 4705, 4738, 4771, 4803,\
     4836, 4869, 4901, 4933, 4966, 4998, 5030, 5062, 5094, 5125, 5157, 5188, 5220, 5251, 5282, 5313,\
     5344, 5375, 5406, 5437, 5467, 5498, 5528, 5559, 5589, 5619, 5649, 5679, 5708, 5738, 5768, 5797,\
     5826, 5856, 5885, 5914, 5943, 5972, 6000, 6029, 6058, 6086, 6114, 6142, 6171, 6199, 6227, 6254,\
     6282, 6310, 6337, 6365, 6392, 6419, 6446, 6473, 6500, 6527, 6554, 6580, 6607, 6633, 6660, 6686,\
     6712, 6738, 6764, 6790, 6815, 6841, 6867, 6892, 6917, 6943, 6968, 6993, 7018, 7043, 7068, 7092,\
     7117, 7141, 7166, 7190, 7214, 7238, 7262, 7286, 7310, 7334, 7358, 7381, 7405, 7428, 7451, 7475,\
     7498, 7521, 7544, 7566, 7589, 7612, 7635, 7657, 7679, 7702, 7724, 7746, 7768, 7790, 7812, 7834,\
     7856, 7877, 7899, 7920, 7942, 7963, 7984, 8005, 8026, 8047, 8068, 8089, 8110, 8131, 8151, 8172,\
     8192, 8212, 8233, 8253, 8273, 8293, 8313, 8333, 8352, 8372, 8392, 8411, 8431, 8450, 8470, 8489}	
#endif /* __MC_CONST_H */
/******************* (C) Bright Power Semiconductor Co.ltd *****END OF FILE****/
